def print_file_info(file_name):
    f = None
    try:
        f = open(file_name,"r",encoding="utf-8")
        content = f.read()
        print(content)
    except Exception as e:
        print(f"程序出现异常了，原因是：{e}")
    finally:
        if f:
            f.close()

def append_to_file(file_name,data):
    '''
    接受路径，传入数据
    :param file_name:
    :param data:
    :return:
    '''
    with open(file_name,"a",encoding="utf-8") as f:
        f.write(data)
        f.write("\n")

if __name__ == '__main__':
    append_to_file("d:/te1st.txt","你好呀~")